/**
 * 封装用户相关操作
 * axios({
 * method: 请求方式
 * data: 请求体中的参数 post/patch/put
 * params:拼接在地址栏中的参数 get/delete
 * headers:请求头(token)
 * })
 */
import http from '@/utils/request.js'
// import { getUser } from '@/utils/storage.js'
/**
 * 用户发送登录请求
 */
export const reqUserLogin = (mobile, code) => {
  return http({
    method: 'post',
    url: '/mp/v1_0/authorizations',
    data: {
      mobile,
      code
    }
  })
}

/**
 * 获取用户身份信息
 */
export const reqGetUserInfo = () => {
  // const userInfo = getUser()
  // console.log(userInfo.token)
  // const userInfo = JSON.parse(localStorage.getItem('token'))
  return http({
    method: 'get',
    url: '/mp/v1_0/user/profile'
  })
}
/**
 * 修改用户信息
 * @param {*} data
 */
export const reqChangeUserInfo = (data) => {
  return http({
    method: 'patch',
    url: '/mp/v1_0/user/profile',
    data
  })
}

// 修改头像
export const reqChangeImg = (formData) => {
  return http({
    method: 'patch',
    url: '/mp/v1_0/user/photo',
    data: formData
  })
}
